package com.cyan.app.workflow.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.cyan.app.workflow.R;

public class Startup extends Activity implements Animation.AnimationListener {
    private static final String TAG = "Startup";

    private ImageView img_startup;
    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_startup);
        img_startup = (ImageView) findViewById(R.id.img_startup);

        Animation animation = AnimationUtils.loadAnimation(this, R.anim.startup);
        animation.setFillAfter(true);
        animation.setAnimationListener(this);

        img_startup.startAnimation(animation);
    }

    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                go();
            }
        }, 1500);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }

    /**
     * 跳转
     */
    private void go() {
        startActivity(new Intent(Startup.this, MainActivity.class));
        finish();
    }
}
